import Profile from "./pages/Profile";
import Home from "./pages/Home";
import About from "./pages/About";
import Category from "./pages/Category";
import { PureComponent } from "react";
import Appstyle from "./style/style";
import { store } from "./store";


class App extends PureComponent
{
    
    constructor()
    {
       super()
       this.state = {
           counter: store.getState().counter   
      }    
    }

    componentDidMount()
    {
        store.subscribe(
            () => {
               const state = store.getState()
               this.setState(
                {
                 counter: state.counter
                }
             )    
            }
        )
    }
    render()
    {
        return (
            <div>
                <h1>counter：{ this.state.counter}</h1>
                <Appstyle>
                    <Home store={store}></Home>
                    <Profile store={store}></Profile>
                    <About></About>
                    <Category></Category>
               </Appstyle>
            </div>
        )
    }
}

export default App;